<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=9"/>
<meta name="generator" content="Doxygen 1.8.11"/>
<title>Superpixel Benchmark: lib_refh/lib/image_graph.h Source File</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="dynsections.js"></script>
<link href="search/search.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="search/searchdata.js"></script>
<script type="text/javascript" src="search/search.js"></script>
<script type="text/javascript">
  $(document).ready(function() { init_search(); });
</script>
<link href="doxygen.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
<div id="titlearea">
<table cellspacing="0" cellpadding="0">
 <tbody>
 <tr style="height: 56px;">
  <td id="projectalign" style="padding-left: 0.5em;">
   <div id="projectname">Superpixel Benchmark
   </div>
   <div id="projectbrief">Superpixel benchmark, tools and algorithms.</div>
  </td>
 </tr>
 </tbody>
</table>
</div>
<!-- end header part -->
<!-- Generated by Doxygen 1.8.11 -->
<script type="text/javascript">
var searchBox = new SearchBox("searchBox", "search",false,'Search');
</script>
  <div id="navrow1" class="tabs">
    <ul class="tablist">
      <li><a href="index.html"><span>Main&#160;Page</span></a></li>
      <li><a href="pages.html"><span>Related&#160;Pages</span></a></li>
      <li><a href="annotated.html"><span>Classes</span></a></li>
      <li class="current"><a href="files.html"><span>Files</span></a></li>
      <li>
        <div id="MSearchBox" class="MSearchBoxInactive">
        <span class="left">
          <img id="MSearchSelect" src="search/mag_sel.png"
               onmouseover="return searchBox.OnSearchSelectShow()"
               onmouseout="return searchBox.OnSearchSelectHide()"
               alt=""/>
          <input type="text" id="MSearchField" value="Search" accesskey="S"
               onfocus="searchBox.OnSearchFieldFocus(true)" 
               onblur="searchBox.OnSearchFieldFocus(false)" 
               onkeyup="searchBox.OnSearchFieldChange(event)"/>
          </span><span class="right">
            <a id="MSearchClose" href="javascript:searchBox.CloseResultsWindow()"><img id="MSearchCloseImg" border="0" src="search/close.png" alt=""/></a>
          </span>
        </div>
      </li>
    </ul>
  </div>
  <div id="navrow2" class="tabs2">
    <ul class="tablist">
      <li><a href="files.html"><span>File&#160;List</span></a></li>
      <li><a href="globals.html"><span>File&#160;Members</span></a></li>
    </ul>
  </div>
<!-- window showing the filter options -->
<div id="MSearchSelectWindow"
     onmouseover="return searchBox.OnSearchSelectShow()"
     onmouseout="return searchBox.OnSearchSelectHide()"
     onkeydown="return searchBox.OnSearchSelectKey(event)">
</div>

<!-- iframe showing the search results (closed by default) -->
<div id="MSearchResultsWindow">
<iframe src="javascript:void(0)" frameborder="0" 
        name="MSearchResults" id="MSearchResults">
</iframe>
</div>

<div id="nav-path" class="navpath">
  <ul>
<li class="navelem"><a class="el" href="dir_3e8ad1512b293df663ab69862f493529.html">lib_refh</a></li><li class="navelem"><a class="el" href="dir_caad8d42ef62baddb9a21b9a73b03d2f.html">lib</a></li>  </ul>
</div>
</div><!-- top -->
<div class="header">
  <div class="headertitle">
<div class="title">image_graph.h</div>  </div>
</div><!--header-->
<div class="contents">
<a href="image__graph_8h.html">Go to the documentation of this file.</a><div class="fragment"><div class="line"><a name="l00001"></a><span class="lineno">    1</span>&#160;</div><div class="line"><a name="l00032"></a><span class="lineno">   32</span>&#160;<span class="preprocessor">#ifndef IMAGE_GRAPH_H</span></div><div class="line"><a name="l00033"></a><span class="lineno">   33</span>&#160;<span class="preprocessor">#define IMAGE_GRAPH_H</span></div><div class="line"><a name="l00034"></a><span class="lineno">   34</span>&#160;</div><div class="line"><a name="l00035"></a><span class="lineno">   35</span>&#160;<span class="preprocessor">#include &lt;assert.h&gt;</span></div><div class="line"><a name="l00036"></a><span class="lineno">   36</span>&#160;<span class="preprocessor">#include &lt;vector&gt;</span></div><div class="line"><a name="l00037"></a><span class="lineno">   37</span>&#160;<span class="preprocessor">#include &lt;map&gt;</span></div><div class="line"><a name="l00038"></a><span class="lineno">   38</span>&#160;<span class="preprocessor">#include &lt;algorithm&gt;</span></div><div class="line"><a name="l00039"></a><span class="lineno">   39</span>&#160;</div><div class="line"><a name="l00044"></a><span class="lineno"><a class="line" href="classImageEdge.html">   44</a></span>&#160;<span class="keyword">class </span><a class="code" href="classImageEdge.html">ImageEdge</a> {</div><div class="line"><a name="l00045"></a><span class="lineno">   45</span>&#160;<span class="keyword">public</span>:</div><div class="line"><a name="l00048"></a><span class="lineno"><a class="line" href="classImageEdge.html#a5e4e84b26f099d2cbc4ad8cf77c801a8">   48</a></span>&#160;    <a class="code" href="classImageEdge.html#aaf0f39fbf136a873d550ee06d9d66ab5">ImageEdge</a>() : <a class="code" href="classImageEdge.html#a5e4e84b26f099d2cbc4ad8cf77c801a8">n</a>(0), <a class="code" href="classImageEdge.html#aaacfcc93020ae91f0fe981d95d720cec">m</a>(0), <a class="code" href="classImageEdge.html#a75943016bab344c88e717f479eea8843">w</a>(0) {};</div><div class="line"><a name="l00049"></a><span class="lineno">   49</span>&#160;    </div><div class="line"><a name="l00051"></a><span class="lineno">   51</span>&#160;    <span class="keywordtype">unsigned</span> <span class="keywordtype">long</span> <span class="keywordtype">int</span> <a class="code" href="classImageEdge.html#a5e4e84b26f099d2cbc4ad8cf77c801a8">n</a>;</div><div class="line"><a name="l00052"></a><span class="lineno">   52</span>&#160;    </div><div class="line"><a name="l00054"></a><span class="lineno"><a class="line" href="classImageEdge.html#aaacfcc93020ae91f0fe981d95d720cec">   54</a></span>&#160;    <span class="keywordtype">unsigned</span> <span class="keywordtype">long</span> <span class="keywordtype">int</span> <a class="code" href="classImageEdge.html#aaacfcc93020ae91f0fe981d95d720cec">m</a>;</div><div class="line"><a name="l00055"></a><span class="lineno">   55</span>&#160;    </div><div class="line"><a name="l00057"></a><span class="lineno"><a class="line" href="classImageEdge.html#a75943016bab344c88e717f479eea8843">   57</a></span>&#160;    <span class="keywordtype">float</span> <a class="code" href="classImageEdge.html#a75943016bab344c88e717f479eea8843">w</a>;</div><div class="line"><a name="l00058"></a><span class="lineno">   58</span>&#160;    </div><div class="line"><a name="l00059"></a><span class="lineno">   59</span>&#160;};</div><div class="line"><a name="l00060"></a><span class="lineno">   60</span>&#160;</div><div class="line"><a name="l00064"></a><span class="lineno"><a class="line" href="classImageEdgeSorter.html">   64</a></span>&#160;<span class="keyword">class </span><a class="code" href="classImageEdgeSorter.html">ImageEdgeSorter</a> {</div><div class="line"><a name="l00065"></a><span class="lineno">   65</span>&#160;<span class="keyword">public</span>:</div><div class="line"><a name="l00071"></a><span class="lineno"><a class="line" href="classImageEdgeSorter.html#a4ffebd8c846a180f3a1f4a1a41528c34">   71</a></span>&#160;    <span class="keyword">inline</span> <span class="keywordtype">bool</span> <a class="code" href="classImageEdgeSorter.html#a4ffebd8c846a180f3a1f4a1a41528c34">operator()</a>(<span class="keyword">const</span> <a class="code" href="classImageEdge.html">ImageEdge</a> &amp; g, <span class="keyword">const</span> <a class="code" href="classImageEdge.html">ImageEdge</a> h) {</div><div class="line"><a name="l00072"></a><span class="lineno">   72</span>&#160;        <span class="keywordflow">return</span> (h.<a class="code" href="classImageEdge.html#a75943016bab344c88e717f479eea8843">w</a> &gt; g.<a class="code" href="classImageEdge.html#a75943016bab344c88e717f479eea8843">w</a>);</div><div class="line"><a name="l00073"></a><span class="lineno">   73</span>&#160;    }</div><div class="line"><a name="l00074"></a><span class="lineno">   74</span>&#160;};</div><div class="line"><a name="l00075"></a><span class="lineno">   75</span>&#160;</div><div class="line"><a name="l00080"></a><span class="lineno"><a class="line" href="classImageNode.html">   80</a></span>&#160;<span class="keyword">class </span><a class="code" href="classImageNode.html">ImageNode</a> {</div><div class="line"><a name="l00081"></a><span class="lineno">   81</span>&#160;<span class="keyword">public</span>:</div><div class="line"><a name="l00084"></a><span class="lineno"><a class="line" href="classImageNode.html#a0cfa4b96eb2ffed75faf83aefc996f7f">   84</a></span>&#160;    <a class="code" href="classImageNode.html#a0cfa4b96eb2ffed75faf83aefc996f7f">ImageNode</a>() : b(0), g(0), r(0), l(0),  <a class="code" href="classImageEdge.html#a5e4e84b26f099d2cbc4ad8cf77c801a8">n</a>(1),  id(0), max_w(0) {</div><div class="line"><a name="l00085"></a><span class="lineno">   85</span>&#160;                </div><div class="line"><a name="l00086"></a><span class="lineno"><a class="line" href="classImageNode.html#ac87d02969990f343f115eb651c9c27a6">   86</a></span>&#160;    };</div><div class="line"><a name="l00087"></a><span class="lineno">   87</span>&#160;    </div><div class="line"><a name="l00089"></a><span class="lineno">   89</span>&#160;    <span class="keywordtype">unsigned</span> <span class="keywordtype">char</span> <a class="code" href="classImageNode.html#ac87d02969990f343f115eb651c9c27a6">b</a>;</div><div class="line"><a name="l00090"></a><span class="lineno">   90</span>&#160;    </div><div class="line"><a name="l00092"></a><span class="lineno"><a class="line" href="classImageNode.html#a3afa3dc020507c774d4fa6e0923125b9">   92</a></span>&#160;    <span class="keywordtype">unsigned</span> <span class="keywordtype">char</span> <a class="code" href="classImageNode.html#a3afa3dc020507c774d4fa6e0923125b9">g</a>;</div><div class="line"><a name="l00093"></a><span class="lineno">   93</span>&#160;    </div><div class="line"><a name="l00095"></a><span class="lineno"><a class="line" href="classImageNode.html#a86f3aac88fc636b0df9dacfaebb5aacf">   95</a></span>&#160;    <span class="keywordtype">unsigned</span> <span class="keywordtype">char</span> <a class="code" href="classImageNode.html#a86f3aac88fc636b0df9dacfaebb5aacf">r</a>;</div><div class="line"><a name="l00096"></a><span class="lineno">   96</span>&#160;    </div><div class="line"><a name="l00098"></a><span class="lineno"><a class="line" href="classImageNode.html#aee7685a31a2969f8f65a688e4cbf23c8">   98</a></span>&#160;    <span class="keywordtype">unsigned</span> <span class="keywordtype">long</span> <span class="keywordtype">int</span> <a class="code" href="classImageNode.html#aee7685a31a2969f8f65a688e4cbf23c8">l</a>; <span class="comment">// label, i.e. the index of the node this node belongs to</span></div><div class="line"><a name="l00099"></a><span class="lineno">   99</span>&#160;    </div><div class="line"><a name="l00101"></a><span class="lineno"><a class="line" href="classImageNode.html#a7de8ae92a9850e192963bb92843bfdfd">  101</a></span>&#160;    <span class="keywordtype">unsigned</span> <span class="keywordtype">long</span> <span class="keywordtype">int</span> <a class="code" href="classImageNode.html#a7de8ae92a9850e192963bb92843bfdfd">n</a>;</div><div class="line"><a name="l00102"></a><span class="lineno">  102</span>&#160;    </div><div class="line"><a name="l00104"></a><span class="lineno"><a class="line" href="classImageNode.html#a0d2d9223d0843c1c993b11683d4b0228">  104</a></span>&#160;    <span class="keywordtype">unsigned</span> <span class="keywordtype">long</span> <span class="keywordtype">int</span> <a class="code" href="classImageNode.html#a0d2d9223d0843c1c993b11683d4b0228">id</a>;</div><div class="line"><a name="l00105"></a><span class="lineno">  105</span>&#160;    </div><div class="line"><a name="l00107"></a><span class="lineno"><a class="line" href="classImageNode.html#a0b28fde40ffadf4dfe8abdbd14585f8f">  107</a></span>&#160;    <span class="keywordtype">float</span> <a class="code" href="classImageNode.html#a0b28fde40ffadf4dfe8abdbd14585f8f">max_w</a>;</div><div class="line"><a name="l00108"></a><span class="lineno">  108</span>&#160;    </div><div class="line"><a name="l00109"></a><span class="lineno">  109</span>&#160;};</div><div class="line"><a name="l00110"></a><span class="lineno">  110</span>&#160;</div><div class="line"><a name="l00115"></a><span class="lineno"><a class="line" href="classImageGraph.html">  115</a></span>&#160;<span class="keyword">class </span><a class="code" href="classImageGraph.html">ImageGraph</a> {</div><div class="line"><a name="l00116"></a><span class="lineno">  116</span>&#160;<span class="keyword">public</span>:</div><div class="line"><a name="l00119"></a><span class="lineno"><a class="line" href="classImageGraph.html#ab63f706cd24f1650af6486b2261e346a">  119</a></span>&#160;    <a class="code" href="classImageGraph.html#ab63f706cd24f1650af6486b2261e346a">ImageGraph</a>() {</div><div class="line"><a name="l00120"></a><span class="lineno">  120</span>&#160;        K = 0;</div><div class="line"><a name="l00121"></a><span class="lineno">  121</span>&#160;    };</div><div class="line"><a name="l00122"></a><span class="lineno">  122</span>&#160;    </div><div class="line"><a name="l00126"></a><span class="lineno"><a class="line" href="classImageGraph.html#a72190c2a9a296ead91b3c4d3282432bc">  126</a></span>&#160;    <a class="code" href="classImageGraph.html#a72190c2a9a296ead91b3c4d3282432bc">ImageGraph</a>(<span class="keywordtype">int</span> N) {</div><div class="line"><a name="l00127"></a><span class="lineno">  127</span>&#160;        nodes = std::vector&lt;ImageNode&gt;(N);</div><div class="line"><a name="l00128"></a><span class="lineno">  128</span>&#160;        K = N;</div><div class="line"><a name="l00129"></a><span class="lineno">  129</span>&#160;    }</div><div class="line"><a name="l00130"></a><span class="lineno">  130</span>&#160;    </div><div class="line"><a name="l00134"></a><span class="lineno"><a class="line" href="classImageGraph.html#a07da5c2a67a5ddc3deea92596a81f997">  134</a></span>&#160;    <span class="keywordtype">void</span> <a class="code" href="classImageGraph.html#a07da5c2a67a5ddc3deea92596a81f997">operator=</a>(<span class="keyword">const</span> <a class="code" href="classImageGraph.html">ImageGraph</a> &amp; graph) {</div><div class="line"><a name="l00135"></a><span class="lineno">  135</span>&#160;        nodes = graph.nodes;</div><div class="line"><a name="l00136"></a><span class="lineno">  136</span>&#160;        edges = graph.edges;</div><div class="line"><a name="l00137"></a><span class="lineno">  137</span>&#160;        K = graph.K;</div><div class="line"><a name="l00138"></a><span class="lineno">  138</span>&#160;    }</div><div class="line"><a name="l00139"></a><span class="lineno">  139</span>&#160;    </div><div class="line"><a name="l00144"></a><span class="lineno"><a class="line" href="classImageGraph.html#a5549bd8ab5b3c1b6fb524d33858c0afe">  144</a></span>&#160;    <span class="keywordtype">void</span> <a class="code" href="classImageGraph.html#a5549bd8ab5b3c1b6fb524d33858c0afe">setNode</a>(<span class="keywordtype">int</span> <a class="code" href="classImageEdge.html#a5e4e84b26f099d2cbc4ad8cf77c801a8">n</a>, <a class="code" href="classImageNode.html">ImageNode</a> &amp; node) {</div><div class="line"><a name="l00145"></a><span class="lineno">  145</span>&#160;        nodes[<a class="code" href="classImageEdge.html#a5e4e84b26f099d2cbc4ad8cf77c801a8">n</a>] = node;</div><div class="line"><a name="l00146"></a><span class="lineno">  146</span>&#160;    }</div><div class="line"><a name="l00147"></a><span class="lineno">  147</span>&#160;    </div><div class="line"><a name="l00151"></a><span class="lineno"><a class="line" href="classImageGraph.html#adc5954519dfc70ffc20b0c069e918d2d">  151</a></span>&#160;    <span class="keywordtype">void</span> <a class="code" href="classImageGraph.html#adc5954519dfc70ffc20b0c069e918d2d">addNode</a>(<a class="code" href="classImageNode.html">ImageNode</a> &amp; node) {</div><div class="line"><a name="l00152"></a><span class="lineno">  152</span>&#160;        nodes.push_back(node);</div><div class="line"><a name="l00153"></a><span class="lineno">  153</span>&#160;        K++;</div><div class="line"><a name="l00154"></a><span class="lineno">  154</span>&#160;    }</div><div class="line"><a name="l00155"></a><span class="lineno">  155</span>&#160;    </div><div class="line"><a name="l00159"></a><span class="lineno"><a class="line" href="classImageGraph.html#ad77bd1b2368e874bf2e5c67eaced6905">  159</a></span>&#160;    <span class="keywordtype">void</span> <a class="code" href="classImageGraph.html#ad77bd1b2368e874bf2e5c67eaced6905">addEdge</a>(<a class="code" href="classImageEdge.html">ImageEdge</a> &amp; edge) {</div><div class="line"><a name="l00160"></a><span class="lineno">  160</span>&#160;        edges.push_back(edge);</div><div class="line"><a name="l00161"></a><span class="lineno">  161</span>&#160;    }</div><div class="line"><a name="l00162"></a><span class="lineno">  162</span>&#160;    </div><div class="line"><a name="l00167"></a><span class="lineno"><a class="line" href="classImageGraph.html#aae238a2319db880455dd385c3f51cf1f">  167</a></span>&#160;    <a class="code" href="classImageNode.html">ImageNode</a> &amp; <a class="code" href="classImageGraph.html#aae238a2319db880455dd385c3f51cf1f">getNode</a>(<span class="keywordtype">int</span> <a class="code" href="classImageEdge.html#a5e4e84b26f099d2cbc4ad8cf77c801a8">n</a>) {</div><div class="line"><a name="l00168"></a><span class="lineno">  168</span>&#160;        assert(n &gt;= 0 &amp;&amp; n &lt; static_cast&lt;int&gt;(nodes.size()));</div><div class="line"><a name="l00169"></a><span class="lineno">  169</span>&#160;        <span class="keywordflow">return</span> nodes[<a class="code" href="classImageEdge.html#a5e4e84b26f099d2cbc4ad8cf77c801a8">n</a>];</div><div class="line"><a name="l00170"></a><span class="lineno">  170</span>&#160;    }</div><div class="line"><a name="l00171"></a><span class="lineno">  171</span>&#160;    </div><div class="line"><a name="l00175"></a><span class="lineno"><a class="line" href="classImageGraph.html#aa62bfaa81c71692d0ff3f06c800ccd0a">  175</a></span>&#160;    <a class="code" href="classImageEdge.html">ImageEdge</a> &amp; <a class="code" href="classImageGraph.html#aa62bfaa81c71692d0ff3f06c800ccd0a">getEdge</a>(<span class="keywordtype">int</span> e) {</div><div class="line"><a name="l00176"></a><span class="lineno">  176</span>&#160;        assert(e &gt;= 0 &amp;&amp; e &lt; static_cast&lt;int&gt;(edges.size()));</div><div class="line"><a name="l00177"></a><span class="lineno">  177</span>&#160;        <span class="keywordflow">return</span> edges[e];</div><div class="line"><a name="l00178"></a><span class="lineno">  178</span>&#160;    }</div><div class="line"><a name="l00179"></a><span class="lineno">  179</span>&#160;    </div><div class="line"><a name="l00183"></a><span class="lineno"><a class="line" href="classImageGraph.html#ad9dc95412a7f22277475b1ddb2e3a963">  183</a></span>&#160;    <span class="keywordtype">int</span> <a class="code" href="classImageGraph.html#ad9dc95412a7f22277475b1ddb2e3a963">getNumNodes</a>() {</div><div class="line"><a name="l00184"></a><span class="lineno">  184</span>&#160;        <span class="keywordflow">return</span> nodes.size();</div><div class="line"><a name="l00185"></a><span class="lineno">  185</span>&#160;    }</div><div class="line"><a name="l00186"></a><span class="lineno">  186</span>&#160;    </div><div class="line"><a name="l00190"></a><span class="lineno"><a class="line" href="classImageGraph.html#a871c65e9e308b068341fc618c1afb63f">  190</a></span>&#160;    <span class="keywordtype">int</span> <a class="code" href="classImageGraph.html#a871c65e9e308b068341fc618c1afb63f">getNumEdges</a>() {</div><div class="line"><a name="l00191"></a><span class="lineno">  191</span>&#160;        <span class="keywordflow">return</span> edges.size();</div><div class="line"><a name="l00192"></a><span class="lineno">  192</span>&#160;    }</div><div class="line"><a name="l00196"></a><span class="lineno"><a class="line" href="classImageGraph.html#ab6bd5512e2e8cec1445d24f5b1f670f8">  196</a></span>&#160;    <span class="keywordtype">int</span> <a class="code" href="classImageGraph.html#ab6bd5512e2e8cec1445d24f5b1f670f8">getNumComponents</a>() {</div><div class="line"><a name="l00197"></a><span class="lineno">  197</span>&#160;        <span class="keywordflow">return</span> K;</div><div class="line"><a name="l00198"></a><span class="lineno">  198</span>&#160;    }</div><div class="line"><a name="l00199"></a><span class="lineno">  199</span>&#160;    </div><div class="line"><a name="l00202"></a><span class="lineno"><a class="line" href="classImageGraph.html#a8c618f7f1fed0e358b0351af6c541d71">  202</a></span>&#160;    <span class="keywordtype">void</span> <a class="code" href="classImageGraph.html#a8c618f7f1fed0e358b0351af6c541d71">sortEdges</a>() {</div><div class="line"><a name="l00203"></a><span class="lineno">  203</span>&#160;        std::sort(edges.begin(), edges.end(), <a class="code" href="classImageEdgeSorter.html">ImageEdgeSorter</a>());</div><div class="line"><a name="l00204"></a><span class="lineno">  204</span>&#160;    }</div><div class="line"><a name="l00205"></a><span class="lineno">  205</span>&#160;    </div><div class="line"><a name="l00213"></a><span class="lineno"><a class="line" href="classImageGraph.html#ab7dbef0113820b967655dd229ff68ccc">  213</a></span>&#160;    <a class="code" href="classImageNode.html">ImageNode</a> &amp; <a class="code" href="classImageGraph.html#ab7dbef0113820b967655dd229ff68ccc">findNodeComponent</a>(<a class="code" href="classImageNode.html">ImageNode</a> &amp; <a class="code" href="classImageEdge.html#a5e4e84b26f099d2cbc4ad8cf77c801a8">n</a>) {</div><div class="line"><a name="l00214"></a><span class="lineno">  214</span>&#160;        </div><div class="line"><a name="l00215"></a><span class="lineno">  215</span>&#160;        <span class="comment">// Get component of node n.</span></div><div class="line"><a name="l00216"></a><span class="lineno">  216</span>&#160;        <span class="keywordtype">int</span> l = n.<a class="code" href="classImageNode.html#aee7685a31a2969f8f65a688e4cbf23c8">l</a>;</div><div class="line"><a name="l00217"></a><span class="lineno">  217</span>&#160;        <span class="keywordtype">int</span> <span class="keywordtype">id</span> = n.<a class="code" href="classImageNode.html#a0d2d9223d0843c1c993b11683d4b0228">id</a>;</div><div class="line"><a name="l00218"></a><span class="lineno">  218</span>&#160;        </div><div class="line"><a name="l00219"></a><span class="lineno">  219</span>&#160;        <span class="keywordflow">while</span> (l != <span class="keywordtype">id</span>) {</div><div class="line"><a name="l00220"></a><span class="lineno">  220</span>&#160;            <span class="keywordtype">id</span> = nodes[l].id;</div><div class="line"><a name="l00221"></a><span class="lineno">  221</span>&#160;            l = nodes[l].l;</div><div class="line"><a name="l00222"></a><span class="lineno">  222</span>&#160;        }</div><div class="line"><a name="l00223"></a><span class="lineno">  223</span>&#160;        </div><div class="line"><a name="l00224"></a><span class="lineno">  224</span>&#160;        <a class="code" href="classImageNode.html">ImageNode</a> &amp; S = nodes[l];</div><div class="line"><a name="l00225"></a><span class="lineno">  225</span>&#160;        assert(S.<a class="code" href="classImageNode.html#aee7685a31a2969f8f65a688e4cbf23c8">l</a> == S.<a class="code" href="classImageNode.html#a0d2d9223d0843c1c993b11683d4b0228">id</a>);</div><div class="line"><a name="l00226"></a><span class="lineno">  226</span>&#160;        </div><div class="line"><a name="l00227"></a><span class="lineno">  227</span>&#160;        <span class="comment">// Save latest component.</span></div><div class="line"><a name="l00228"></a><span class="lineno">  228</span>&#160;        n.<a class="code" href="classImageNode.html#aee7685a31a2969f8f65a688e4cbf23c8">l</a> = S.<a class="code" href="classImageNode.html#a0d2d9223d0843c1c993b11683d4b0228">id</a>;</div><div class="line"><a name="l00229"></a><span class="lineno">  229</span>&#160;        </div><div class="line"><a name="l00230"></a><span class="lineno">  230</span>&#160;        <span class="keywordflow">return</span> S;</div><div class="line"><a name="l00231"></a><span class="lineno">  231</span>&#160;    }</div><div class="line"><a name="l00232"></a><span class="lineno">  232</span>&#160;    </div><div class="line"><a name="l00242"></a><span class="lineno"><a class="line" href="classImageGraph.html#a7b39c32164fbca6272c5684577941e46">  242</a></span>&#160;    <span class="keywordtype">void</span> <a class="code" href="classImageGraph.html#a7b39c32164fbca6272c5684577941e46">merge</a>(<a class="code" href="classImageNode.html">ImageNode</a> &amp; S_n, <a class="code" href="classImageNode.html">ImageNode</a> &amp; S_m, <a class="code" href="classImageEdge.html">ImageEdge</a> &amp; e) {</div><div class="line"><a name="l00243"></a><span class="lineno">  243</span>&#160;        S_m.<a class="code" href="classImageNode.html#aee7685a31a2969f8f65a688e4cbf23c8">l</a> = S_n.<a class="code" href="classImageNode.html#a0d2d9223d0843c1c993b11683d4b0228">id</a>;</div><div class="line"><a name="l00244"></a><span class="lineno">  244</span>&#160;        </div><div class="line"><a name="l00245"></a><span class="lineno">  245</span>&#160;        <span class="comment">// Update cound.</span></div><div class="line"><a name="l00246"></a><span class="lineno">  246</span>&#160;        S_n.<a class="code" href="classImageNode.html#a7de8ae92a9850e192963bb92843bfdfd">n</a> += S_m.<a class="code" href="classImageNode.html#a7de8ae92a9850e192963bb92843bfdfd">n</a>;</div><div class="line"><a name="l00247"></a><span class="lineno">  247</span>&#160;        </div><div class="line"><a name="l00248"></a><span class="lineno">  248</span>&#160;        <span class="comment">// Update maximum weight.</span></div><div class="line"><a name="l00249"></a><span class="lineno">  249</span>&#160;        S_n.<a class="code" href="classImageNode.html#a0b28fde40ffadf4dfe8abdbd14585f8f">max_w</a> = std::max(std::max(S_n.<a class="code" href="classImageNode.html#a0b28fde40ffadf4dfe8abdbd14585f8f">max_w</a>, S_m.<a class="code" href="classImageNode.html#a0b28fde40ffadf4dfe8abdbd14585f8f">max_w</a>), e.<a class="code" href="classImageEdge.html#a75943016bab344c88e717f479eea8843">w</a>);</div><div class="line"><a name="l00250"></a><span class="lineno">  250</span>&#160;        </div><div class="line"><a name="l00251"></a><span class="lineno">  251</span>&#160;        <span class="comment">// Update component count.</span></div><div class="line"><a name="l00252"></a><span class="lineno">  252</span>&#160;        K--;</div><div class="line"><a name="l00253"></a><span class="lineno">  253</span>&#160;    }</div><div class="line"><a name="l00254"></a><span class="lineno">  254</span>&#160;    </div><div class="line"><a name="l00255"></a><span class="lineno">  255</span>&#160;<span class="keyword">private</span>:</div><div class="line"><a name="l00256"></a><span class="lineno">  256</span>&#160;    </div><div class="line"><a name="l00258"></a><span class="lineno">  258</span>&#160;    <span class="keywordtype">int</span> K;</div><div class="line"><a name="l00259"></a><span class="lineno">  259</span>&#160;    </div><div class="line"><a name="l00261"></a><span class="lineno">  261</span>&#160;    std::vector&lt;ImageEdge&gt; edges;</div><div class="line"><a name="l00262"></a><span class="lineno">  262</span>&#160;    </div><div class="line"><a name="l00264"></a><span class="lineno">  264</span>&#160;    std::vector&lt;ImageNode&gt; nodes;</div><div class="line"><a name="l00265"></a><span class="lineno">  265</span>&#160;    </div><div class="line"><a name="l00266"></a><span class="lineno">  266</span>&#160;};</div><div class="line"><a name="l00267"></a><span class="lineno">  267</span>&#160;</div><div class="line"><a name="l00268"></a><span class="lineno">  268</span>&#160;<span class="preprocessor">#endif  </span><span class="comment">/* IMAGE_GRAPH_H */</span><span class="preprocessor"></span></div><div class="line"><a name="l00269"></a><span class="lineno">  269</span>&#160;</div><div class="ttc" id="classImageGraph_html_a8c618f7f1fed0e358b0351af6c541d71"><div class="ttname"><a href="classImageGraph.html#a8c618f7f1fed0e358b0351af6c541d71">ImageGraph::sortEdges</a></div><div class="ttdeci">void sortEdges()</div><div class="ttdoc">Sort the edges by weight. </div><div class="ttdef"><b>Definition:</b> image_graph.h:202</div></div>
<div class="ttc" id="classImageNode_html_a7de8ae92a9850e192963bb92843bfdfd"><div class="ttname"><a href="classImageNode.html#a7de8ae92a9850e192963bb92843bfdfd">ImageNode::n</a></div><div class="ttdeci">unsigned long int n</div><div class="ttdoc">Size of node after merging with other nodes. </div><div class="ttdef"><b>Definition:</b> image_graph.h:101</div></div>
<div class="ttc" id="classImageGraph_html_ab6bd5512e2e8cec1445d24f5b1f670f8"><div class="ttname"><a href="classImageGraph.html#ab6bd5512e2e8cec1445d24f5b1f670f8">ImageGraph::getNumComponents</a></div><div class="ttdeci">int getNumComponents()</div><div class="ttdoc">Get number of connected components. </div><div class="ttdef"><b>Definition:</b> image_graph.h:196</div></div>
<div class="ttc" id="classImageNode_html_a0b28fde40ffadf4dfe8abdbd14585f8f"><div class="ttname"><a href="classImageNode.html#a0b28fde40ffadf4dfe8abdbd14585f8f">ImageNode::max_w</a></div><div class="ttdeci">float max_w</div><div class="ttdoc">Maximum weight. </div><div class="ttdef"><b>Definition:</b> image_graph.h:107</div></div>
<div class="ttc" id="classImageGraph_html_a871c65e9e308b068341fc618c1afb63f"><div class="ttname"><a href="classImageGraph.html#a871c65e9e308b068341fc618c1afb63f">ImageGraph::getNumEdges</a></div><div class="ttdeci">int getNumEdges()</div><div class="ttdoc">Get the number of edges. </div><div class="ttdef"><b>Definition:</b> image_graph.h:190</div></div>
<div class="ttc" id="classImageNode_html"><div class="ttname"><a href="classImageNode.html">ImageNode</a></div><div class="ttdoc">Represents a pixel in a video. Each pixel is represented by its color which is needed to compute the ...</div><div class="ttdef"><b>Definition:</b> image_graph.h:80</div></div>
<div class="ttc" id="classImageGraph_html_adc5954519dfc70ffc20b0c069e918d2d"><div class="ttname"><a href="classImageGraph.html#adc5954519dfc70ffc20b0c069e918d2d">ImageGraph::addNode</a></div><div class="ttdeci">void addNode(ImageNode &amp;node)</div><div class="ttdoc">Add a new node. </div><div class="ttdef"><b>Definition:</b> image_graph.h:151</div></div>
<div class="ttc" id="classImageGraph_html_ab63f706cd24f1650af6486b2261e346a"><div class="ttname"><a href="classImageGraph.html#ab63f706cd24f1650af6486b2261e346a">ImageGraph::ImageGraph</a></div><div class="ttdeci">ImageGraph()</div><div class="ttdoc">Default constructor. </div><div class="ttdef"><b>Definition:</b> image_graph.h:119</div></div>
<div class="ttc" id="classImageNode_html_ac87d02969990f343f115eb651c9c27a6"><div class="ttname"><a href="classImageNode.html#ac87d02969990f343f115eb651c9c27a6">ImageNode::b</a></div><div class="ttdeci">unsigned char b</div><div class="ttdoc">Blue channel. </div><div class="ttdef"><b>Definition:</b> image_graph.h:86</div></div>
<div class="ttc" id="classImageGraph_html_a07da5c2a67a5ddc3deea92596a81f997"><div class="ttname"><a href="classImageGraph.html#a07da5c2a67a5ddc3deea92596a81f997">ImageGraph::operator=</a></div><div class="ttdeci">void operator=(const ImageGraph &amp;graph)</div><div class="ttdoc">Assignment operator. </div><div class="ttdef"><b>Definition:</b> image_graph.h:134</div></div>
<div class="ttc" id="classImageEdge_html_a5e4e84b26f099d2cbc4ad8cf77c801a8"><div class="ttname"><a href="classImageEdge.html#a5e4e84b26f099d2cbc4ad8cf77c801a8">ImageEdge::n</a></div><div class="ttdeci">unsigned long int n</div><div class="ttdoc">Index of first node. </div><div class="ttdef"><b>Definition:</b> image_graph.h:48</div></div>
<div class="ttc" id="classImageGraph_html_aae238a2319db880455dd385c3f51cf1f"><div class="ttname"><a href="classImageGraph.html#aae238a2319db880455dd385c3f51cf1f">ImageGraph::getNode</a></div><div class="ttdeci">ImageNode &amp; getNode(int n)</div><div class="ttdef"><b>Definition:</b> image_graph.h:167</div></div>
<div class="ttc" id="classImageGraph_html_a72190c2a9a296ead91b3c4d3282432bc"><div class="ttname"><a href="classImageGraph.html#a72190c2a9a296ead91b3c4d3282432bc">ImageGraph::ImageGraph</a></div><div class="ttdeci">ImageGraph(int N)</div><div class="ttdoc">Constructs an image graph with the given exact number of nodes. </div><div class="ttdef"><b>Definition:</b> image_graph.h:126</div></div>
<div class="ttc" id="classImageEdgeSorter_html"><div class="ttname"><a href="classImageEdgeSorter.html">ImageEdgeSorter</a></div><div class="ttdoc">Class for sorting edges according to weight. </div><div class="ttdef"><b>Definition:</b> image_graph.h:64</div></div>
<div class="ttc" id="classImageEdge_html_aaacfcc93020ae91f0fe981d95d720cec"><div class="ttname"><a href="classImageEdge.html#aaacfcc93020ae91f0fe981d95d720cec">ImageEdge::m</a></div><div class="ttdeci">unsigned long int m</div><div class="ttdoc">Index of second node. </div><div class="ttdef"><b>Definition:</b> image_graph.h:54</div></div>
<div class="ttc" id="classImageNode_html_a86f3aac88fc636b0df9dacfaebb5aacf"><div class="ttname"><a href="classImageNode.html#a86f3aac88fc636b0df9dacfaebb5aacf">ImageNode::r</a></div><div class="ttdeci">unsigned char r</div><div class="ttdoc">Red channel. </div><div class="ttdef"><b>Definition:</b> image_graph.h:95</div></div>
<div class="ttc" id="classImageNode_html_a3afa3dc020507c774d4fa6e0923125b9"><div class="ttname"><a href="classImageNode.html#a3afa3dc020507c774d4fa6e0923125b9">ImageNode::g</a></div><div class="ttdeci">unsigned char g</div><div class="ttdoc">Green channel. </div><div class="ttdef"><b>Definition:</b> image_graph.h:92</div></div>
<div class="ttc" id="classImageGraph_html_a5549bd8ab5b3c1b6fb524d33858c0afe"><div class="ttname"><a href="classImageGraph.html#a5549bd8ab5b3c1b6fb524d33858c0afe">ImageGraph::setNode</a></div><div class="ttdeci">void setNode(int n, ImageNode &amp;node)</div><div class="ttdoc">Set the node of the given index. </div><div class="ttdef"><b>Definition:</b> image_graph.h:144</div></div>
<div class="ttc" id="classImageNode_html_aee7685a31a2969f8f65a688e4cbf23c8"><div class="ttname"><a href="classImageNode.html#aee7685a31a2969f8f65a688e4cbf23c8">ImageNode::l</a></div><div class="ttdeci">unsigned long int l</div><div class="ttdoc">The label of the pixel. </div><div class="ttdef"><b>Definition:</b> image_graph.h:98</div></div>
<div class="ttc" id="classImageGraph_html"><div class="ttname"><a href="classImageGraph.html">ImageGraph</a></div><div class="ttdoc">Represents an image graph, consisting of one node per pixel which are 4-connected. </div><div class="ttdef"><b>Definition:</b> image_graph.h:115</div></div>
<div class="ttc" id="classImageGraph_html_ab7dbef0113820b967655dd229ff68ccc"><div class="ttname"><a href="classImageGraph.html#ab7dbef0113820b967655dd229ff68ccc">ImageGraph::findNodeComponent</a></div><div class="ttdeci">ImageNode &amp; findNodeComponent(ImageNode &amp;n)</div><div class="ttdoc">When two nodes get merged, the first node is assigned the id of the second node as label...</div><div class="ttdef"><b>Definition:</b> image_graph.h:213</div></div>
<div class="ttc" id="classImageGraph_html_ad9dc95412a7f22277475b1ddb2e3a963"><div class="ttname"><a href="classImageGraph.html#ad9dc95412a7f22277475b1ddb2e3a963">ImageGraph::getNumNodes</a></div><div class="ttdeci">int getNumNodes()</div><div class="ttdoc">Get the number of nodes. </div><div class="ttdef"><b>Definition:</b> image_graph.h:183</div></div>
<div class="ttc" id="classImageEdge_html_a75943016bab344c88e717f479eea8843"><div class="ttname"><a href="classImageEdge.html#a75943016bab344c88e717f479eea8843">ImageEdge::w</a></div><div class="ttdeci">float w</div><div class="ttdoc">Edge weight. </div><div class="ttdef"><b>Definition:</b> image_graph.h:57</div></div>
<div class="ttc" id="classImageGraph_html_aa62bfaa81c71692d0ff3f06c800ccd0a"><div class="ttname"><a href="classImageGraph.html#aa62bfaa81c71692d0ff3f06c800ccd0a">ImageGraph::getEdge</a></div><div class="ttdeci">ImageEdge &amp; getEdge(int e)</div><div class="ttdoc">Get the e-th edge in the current sorting. </div><div class="ttdef"><b>Definition:</b> image_graph.h:175</div></div>
<div class="ttc" id="classImageEdge_html"><div class="ttname"><a href="classImageEdge.html">ImageEdge</a></div><div class="ttdoc">Represents an edge between two pixels in an image. Each edge is characterized by a weight and the adj...</div><div class="ttdef"><b>Definition:</b> image_graph.h:44</div></div>
<div class="ttc" id="classImageEdgeSorter_html_a4ffebd8c846a180f3a1f4a1a41528c34"><div class="ttname"><a href="classImageEdgeSorter.html#a4ffebd8c846a180f3a1f4a1a41528c34">ImageEdgeSorter::operator()</a></div><div class="ttdeci">bool operator()(const ImageEdge &amp;g, const ImageEdge h)</div><div class="ttdoc">Compare to edges according to their weights. </div><div class="ttdef"><b>Definition:</b> image_graph.h:71</div></div>
<div class="ttc" id="classImageNode_html_a0d2d9223d0843c1c993b11683d4b0228"><div class="ttname"><a href="classImageNode.html#a0d2d9223d0843c1c993b11683d4b0228">ImageNode::id</a></div><div class="ttdeci">unsigned long int id</div><div class="ttdoc">Id of the node. </div><div class="ttdef"><b>Definition:</b> image_graph.h:104</div></div>
<div class="ttc" id="classImageNode_html_a0cfa4b96eb2ffed75faf83aefc996f7f"><div class="ttname"><a href="classImageNode.html#a0cfa4b96eb2ffed75faf83aefc996f7f">ImageNode::ImageNode</a></div><div class="ttdeci">ImageNode()</div><div class="ttdoc">Default constructor. </div><div class="ttdef"><b>Definition:</b> image_graph.h:84</div></div>
<div class="ttc" id="classImageEdge_html_aaf0f39fbf136a873d550ee06d9d66ab5"><div class="ttname"><a href="classImageEdge.html#aaf0f39fbf136a873d550ee06d9d66ab5">ImageEdge::ImageEdge</a></div><div class="ttdeci">ImageEdge()</div><div class="ttdoc">Default constructor. </div><div class="ttdef"><b>Definition:</b> image_graph.h:48</div></div>
<div class="ttc" id="classImageGraph_html_ad77bd1b2368e874bf2e5c67eaced6905"><div class="ttname"><a href="classImageGraph.html#ad77bd1b2368e874bf2e5c67eaced6905">ImageGraph::addEdge</a></div><div class="ttdeci">void addEdge(ImageEdge &amp;edge)</div><div class="ttdoc">Add a new edge. </div><div class="ttdef"><b>Definition:</b> image_graph.h:159</div></div>
<div class="ttc" id="classImageGraph_html_a7b39c32164fbca6272c5684577941e46"><div class="ttname"><a href="classImageGraph.html#a7b39c32164fbca6272c5684577941e46">ImageGraph::merge</a></div><div class="ttdeci">void merge(ImageNode &amp;S_n, ImageNode &amp;S_m, ImageEdge &amp;e)</div><div class="ttdoc">Merge two pixels (that is merge two nodes). </div><div class="ttdef"><b>Definition:</b> image_graph.h:242</div></div>
</div><!-- fragment --></div><!-- contents -->
<!-- start footer part -->
<hr class="footer"/><address class="footer"><small>
Generated on Sun Apr 16 2017 16:39:17 for Superpixel Benchmark by &#160;<a href="http://www.doxygen.org/index.html">
<img class="footer" src="doxygen.png" alt="doxygen"/>
</a> 1.8.11
</small></address>
</body>
</html>
